package pers.cz.job;

import pers.cz.date.DateUtils;
import pers.cz.mapper.AutoCollectMethodParamsMapper;
import pers.cz.model.AutoCollectMethodParamsExample;
import pers.cz.quartz.job.AbstractQuartzJob;
import pers.cz.spring.SpringContextUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;
import java.util.Map;

/**
 * @program: PostGirl-panent
 * @description: ClearCollectMethodJob
 * @author: Cheng Zhi
 * @create: 2022-03-10 18:10
 **/
public class ClearCollectMethodJob extends AbstractQuartzJob {

    @Override
    public void doJob(JobExecutionContext var1, Map params) throws JobExecutionException {
        // 获取当前时间的前二天
        Date date = DateUtils.getBeforeDate(1);
        // 删除大于指定日期的数据
        AutoCollectMethodParamsExample example = new AutoCollectMethodParamsExample();
        AutoCollectMethodParamsExample.Criteria criteria = example.createCriteria();
        criteria.andSyncTimeLessThan(date);
        SpringContextUtil.getBean(AutoCollectMethodParamsMapper.class).deleteByExample(example);
    }
}
